import { computed, ref } from 'vue';

function createBoolRef(name: string, settingOptions: any) {
  const myRef = ref(false);
  const me = computed({
    get() {
      myRef.value = settingOptions.getOption(name) || false;
      return myRef.value;
    },
    set(newValue) {
      myRef.value = newValue;
      settingOptions.setOption(name, newValue);
    }
  });
  return me;
}

function createNumberRef(name: string, settingOptions: any) {
  const myRef = ref(0);
  const me = computed({
    get() {
      myRef.value = settingOptions.getOption(name) || 1;
      return myRef.value;
    },
    set(newValue) {
      myRef.value = newValue;
      settingOptions.setOption(name, newValue);
    }
  });
  return me;
}

function createStringRef(name: string, settingOptions: any) {
  const myRef = ref('FFFFFF');
  const me = computed({
    get() {
      myRef.value = settingOptions.getOption(name) || 1;
      return myRef.value;
    },
    set(newValue) {
      myRef.value = newValue;
      settingOptions.setOption(name, newValue);
    }
  });
  return me;
}

export { createBoolRef, createNumberRef, createStringRef };
